package com.ridu.project.beshid.service.impl;

import com.ridu.project.beshid.api.Category;
import com.ridu.project.beshid.api.GeneralResponse;
import com.ridu.project.beshid.api.Status;
import com.ridu.project.beshid.entity.CategoryEntity;
import com.ridu.project.beshid.repository.CategoryRepository;
import com.ridu.project.beshid.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * Created by user on 2017/10/18.
 */
@Service
@Slf4j
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryRepository repository;

    @Override
    public GeneralResponse findAll() {
        GeneralResponse response = new GeneralResponse();
        try{
            List<CategoryEntity> entities = repository.findAll();
            response.setRows(entities);
            response.setStatus(Status.SUCCESS);
        } catch (Exception e){
            response.setStatus(Status.FAILED);
            response.setMessage(e.getMessage());
        }
        return response;
    }
}
